package nl.infodation.emr.utility;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public final class DateTimeUtil {
	
	public static String DATE_FORMAT = "dd-MM-yyyy";
	public static String DATE_FORMAT_NOW = "yyyyMMddhms";
	public static String DATE_FORMAT_SQL = "yyyy-MM-dd";
	public static Date MIN_DATE = new Date(new Long("283971600000")); // 1979
	public static Date MAX_DATE = new Date(new Long("3439731600000")); // 2079
	
	static public Date getValueWithoutNull(Date value) {
		if (null == value) {
			return new Date();
		}
		return value;
	}
	
	public static String getNow() {
		final SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy h:mma : ", Locale.US);
		final String nowValue = format.format(new Date());
		return nowValue;
	}
	
	public static String getFormatNow() {
		final SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT_NOW, Locale.US);
		final String nowValue = format.format(new Date());
		return nowValue;
	}

	public static String getSqlDate(Date date) {
		if (date == null) {
			date = new Date();
		}
		final SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT_SQL, Locale.US);
		return format.format(date) + " 00:00:00";
	}
}
